import { onLCP, onINP, onClS } from 'web-vitals';
onLCP(console.log);
onINP(console.log);
onClS(console.log);
const resourceTimings = performance.getEntriesByType('resource');
for (const resourceTiming of resourceTimings) {
    console.log(resourceTiming);
}

// 检测白屏时间，fp
const entryHandler = (list) => {
    for (const entry of list.getEntries()) {
        if (entry.name === 'first-paint') {
            observer.disconnect();
        }
        console.log(entry);
        // startTime 即白屏时间
        const fpTime = entry.startTime;
        console.log('fpTime: ', fpTime);
    }
};
const observer = new PerformanceObserver(entryHandler);
// buffered 表示是否观察缓存数据，即观察代码添加时机比事件出发时机晚也没关系
observer.observe({ type: 'paint', buffered: true });
